package com.knowledge.DAO;

import java.sql.Connection;
import java.sql.SQLException;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;

public class DBpool {
	private static DataSource pool;
	static {
		Context context = null;
		try {
			System.out.println("DAO invoked");
			context = new InitialContext();
			pool = (DataSource) context.lookup("java:/comp/env/jdbc/knowledge");
			if (pool == null)
				System.err.println("'DBPool' is an unknown DataSource");
		} catch (NamingException ne) {
			ne.printStackTrace();
		}
	}

	public static Connection getConnection() throws SQLException {
		return pool.getConnection();
	}

}
